package com.atguigu.tingshu.payment.config;



import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class paymentRabbitConfig {

    /**
     * 支付交换机
     * @return
     */
    @Bean
    public Exchange paymentInfoExchange(){
        return ExchangeBuilder.directExchange("paymentInfo_Exchange").build();
    }

    /**
     * 订单队列
     * @return
     */
    @Bean
    public Queue OrderInfoQueue(){
        return QueueBuilder.durable("OrderInfo_Queue").build();
    }

    /**订单那队列绑定交换机
     * @param OrderInfoQueue
     * @param paymentInfoExchange
     * @return
     */
    @Bean
    public Binding OrderInfoBindExchange(@Qualifier(value = "OrderInfoQueue")Queue OrderInfoQueue,
                                        @Qualifier(value = "paymentInfoExchange")Exchange paymentInfoExchange){
        return BindingBuilder.bind(OrderInfoQueue).to(paymentInfoExchange).with("payment_order").noargs();
    }

    /**
     * 充值队列
     * @return
     */
    @Bean
    public Queue AmountQueue(){
        return QueueBuilder.durable("Amount_Queue").build();
    }

    /**
     * 充值对列绑定交换机
     * @param AmountQueue
     * @param paymentInfoExchange
     * @return
     */
    @Bean
    public Binding AmountBindingExchange(@Qualifier(value = "AmountQueue")Queue AmountQueue,
                                         @Qualifier(value = "paymentInfoExchange")Exchange paymentInfoExchange){
        return BindingBuilder.bind(AmountQueue).to(paymentInfoExchange).with("payment_amount").noargs();
    }

}
